<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/style/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="/style/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script src="/js/plugins/artDialog/jquery.artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="/js/plugins/jqueryForm/jquery.form.min.js"></script>
    <script type="text/javascript" src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="/js/commonAll.js"></script>
    <title>WMS-销售出库订单管理</title>
    <style>
        .alt td {
            background: black !important;
        }
    </style>
    <script>
        $(function () {
            $(".btn_audit").click(function () {
                //获取到当前请求事件源对象
                var auditUrl = $(this).data("url");
                showDialog("哥啊,您是要审核吗?想清楚!", function () {
                    $.get(auditUrl, function (data) {
                        if (data.success) {
                            showDialog("审核成功", function () {
                                //重新加载页面
                                window.location.reload();
                            })
                        }else {
                            showDialog(data.msg);
                        }

                    })
                }, true);

            });
            //开始时间 结束时间操作
            $("input[name=startDate]").click(function () {
                WdatePicker({
                    maxDate:$("input[name=endDate]").val()||new Date()
                });
            });
            $("input[name=endDate]").click(function () {
                WdatePicker({
                    minDate:$("input[name=startDate]").val(),
                    maxDate:new Date()
                });
            });
        })

    </script>
</head>
<body>
<form id="searchForm" action="/stockOutcomeBill/list.do" method="post">
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                    <div id="box_top">搜索</div>
                 <div id="box_center">
                        开始时间:<input type="text" name="startDate" value="<fmt:formatDate value="${qo.startDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker()"  class="ui_input_txt02 Wdate">
                        结束时间:<input type="text" name="endDate"  value="<fmt:formatDate value="${qo.endDate}" pattern="yyyy-MM-dd"/>" onclick="WdatePicker()"  class="ui_input_txt02 Wdate">
                        所属仓库:
                        <select class="ui_select01" name="depotId">
                            <option value="-1">全部</option>
                            <c:forEach items="${depots}" var="item">
                                <option value="${item.id}">${item.name}</option>
                            </c:forEach>
                        </select>
                        所在客户:
                        <select class="ui_select01" name="clientId">
                            <option value="-1">全部</option>
                            <c:forEach items="${clients}" var="item">
                                <option value="${item.id}">${item.name}</option>
                            </c:forEach>
                        </select>
                        <script>
                            $(":input[name=depotId] option[value=${qo.depotId}]").prop("selected",true);
                            $(":input[name=clientId] option[value=${qo.clientId}]").prop("selected",true);
                        </script>
                        单据状态:
                        <select class="ui_select01" name="status">
                            <option value="-1">全部</option>
                            <option value="0">未审核</option>
                            <option value="1">已审核</option>
                        </select>
                        <script>
                            $(":input[name=status] option[value=${qo.status}]").prop("selected",true);
                        </script>
                    </div>
                    <div id="box_bottom">
                        <input type="button" value="查询" class="ui_input_btn01 btn_page"data-page="1"/>
                        <input type="button" value="新增" class="ui_input_btn01 btn_input"
                               data-url="/stockOutcomeBill/input.do"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        <th width="30"><input type="checkbox" id="all"/></th>
                        <th>编号</th>
                        <th>订单编码</th>
                        <th>业务时间</th>
                        <th>仓库</th>
                        <th>总金额</th>
                        <th>总数量</th>
                        <th>录入人</th>
                        <th>审核人</th>
                        <th>客户</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    <tbody>
                    <c:forEach items="${pageResult.list}" var="item">
                        <tr>
                            <td><input type="checkbox" name="IDCheck" class="acb"/></td>
                            <td>${item.id}</td>
                            <td>${item.sn}</td>
                            <td>
                                <fmt:formatDate value="${item.vdate}" pattern="yyyy-MM-dd"/>
                            </td>
                            <td>${item.depot.name}</td>
                            <td>${item.totalAmount}</td>
                            <td>${item.totalNumber}</td>
                            <td>${item.inputUser.name}</td>
                            <td>${item.auditor.name}</td>
                            <td>${item.client.name}</td>
                            <td>
                                <span style="color: ${item.status==0?'green':'red'}">${item.status==0?"未审核":"已审核"}</span>
                            </td>
                            <td>
                                <c:choose>
                                    <c:when test="${item.status==0}">
                                        <a href="/stockOutcomeBill/input.do?id=${item.id}">编辑</a>
                                        <a href="javascript:;" class="btn_delete"
                                           data-url="/stockOutcomeBill/delete.do?id=${item.id}">删除</a>
                                        <a href="javascript:;" class="btn_audit"
                                           data-url="/stockOutcomeBill/audit.do?id=${item.id}">审核</a>
                                    </c:when>
                                    <c:otherwise>

                                        <a href="/stockOutcomeBill/view.do?id=${item.id}">查看</a>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <jsp:include page="/WEB-INF/views/common/common_page.jsp"/>
        </div>
    </div>
</form>
</body>
</html>
